//-----------------------------------------------------------------------
// <copyright file="CompanyService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CompanyService
    {
        #region Company

        public static void CreateCompany(Company company)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                companyDAO.CreateCompany(company);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateCompanyException, ex);
            }
        }        

        public static void UpdateCompany(Company company)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                companyDAO.UpdateCompany(company);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateCompanyException, ex);
            }
        }        

        public static void DeleteCompany(long companyID)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                companyDAO.DeleteCompany(companyID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteCompanyException, ex);
            }
        }
        
        public static Company GetCompany(long companyID)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                return companyDAO.GetCompany(companyID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCompanyException, ex);
            }
        }                

        public static CompanyCollection GetCompanyList(CompanyColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                return companyDAO.GetCompanyList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCompanyListException, ex);
            }
        }        

        public static CompanyCollection GetCompanyList(CompanyColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                return companyDAO.GetCompanyList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCompanyListException, ex);
            }
        }        

	    public static CompanyCollection GetCompanyListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                return companyDAO.GetCompanyListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCompanyListException, ex);
            }
        }        

        public static CompanyCollection GetCompanyListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                CompanyDAO companyDAO = new CompanyDAO();
                return companyDAO.GetCompanyListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCompanyListException, ex);
            }
        }        

        #endregion
    }
}